< previous page page_262 next page >

Page 262
The DoACopy function is changed as follows:
' Perform a copy operation
Private Sub DoACopy()
   Dim sh As SHFILEOPSTRUCT
   Dim src$, dest$
   Dim res&

   src$ = GetNullsString(FileList)
   dest$ = "A:\" & Chr$(0) & Chr$(0)

   sh.hwnd = hwnd
   sh.wFunc = FO_COPY
   sh.pFrom = src$
   sh.pTo = dest$
   sh.fFlags = FOF_RENAMEONCOLLISION Or FOF_SIMPLEPROGRESS
   sh.hNameMappings = 0

   res = DoTheShellCall(sh, "Files are being copied to floppy")

End Sub
We also change the SHFILEOPSTRUCT as shown here so that the lpszProgressTitle field is a Long. Why? Because the DoTheShellCall function is going to shift data within the structure, meaning that the data in the lpszProgressTitle field will change (at least from the point of view of Visual Basic). This is a sure path to a memory exception. By changing it to a Long and explicitly setting the variable to a pointer to an ANSI string, you won't have to worry about Visual Basic getting confused about the contents of that field.
Private Type SHFILEOPSTRUCT
        hwnd As Long
        wFunc As Long
        pFrom As String
        pTo As String
        fFlags As Integer
        fAnyOperationsAborted As Long
        hNameMappings As Long
        lpszProgressTitle As Long ' only used if FOF_SIMPLEPROGRESS
End Type

 
< previous page page_262 next page >